<?php

namespace App\Extension;

use Illuminate\Support\Facades\DB;

/**
 * Created by PhpStorm.
 * User: simon
 * Date: 2016/4/21
 * Time: 15:01
 */
class BaseMigration extends \Illuminate\Database\Migrations\Migration
{

    public function statement($sqls)
    {
        $this->do_statement($sqls);
    }

    public function statement_branch($sqls)
    {
        $this->do_statement($sqls, "lt_yingjian");
    }

    private function do_statement($sqls, $db = "")
    {
        $querys = explode(";", $sqls);
        foreach ($querys as $query) {
            if (empty(trim($query))) {
                continue;
            }
            if (empty($db)) {
                DB::statement($query);
            } else {
                DB::connection($db)->statement($query);
            }

        }
    }
}